<?php 
function create_post_type(){
    // Run when init actions are run.
    $customPost = new Custompost();
}
class Custompost{
    public function __construct(){
register_post_type('library', array(	'label' => 'Library','description' => '','public' => true,'show_ui' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => 'library'),'query_var' => true,'menu_position' => 5,'menu_icon' => WPBL_PLUGIN_URL .'/images/library_ico1.png','supports' => array('title','excerpt','thumbnail',),'taxonomies' => array('publishers','authors','editions',$cpt_post_types),'labels' => array (
  'name' => 'Library',
  'singular_name' => __("Library","wpbl"),
  'menu_name' => __("Library","wpbl"),
  'add_new' => __("Details Add Book","wpbl"),
  'add_new_item' => __("Add New Book Detailed Info","wpbl"),
  'edit' => __("Edit","wpbl"),
  'edit_item' => __("Edit Books","wpbl"),
  'new_item' => __("New Books","wpbl"),
  'view' => __("View Books","wpbl"),
  'view_item' => __("View Books","wpbl"),
  'search_items' => __("Search Books","wpbl"),
  'not_found' => __("No Books Found","wpbl"),
  'not_found_in_trash' => __("No Books Found in Trash","wpbl"),
  'parent' => __("Parent Books","wpbl"),
),) );

}
}
function create_taxonomies_type() {
	//register custom taxonomies
	$cpt_tax_types = get_option('cpt_custom_tax_types');
	//check if option value is an array before proceeding
	if ( is_array( $cpt_tax_types ) ) {
		foreach ($cpt_tax_types as $cpt_tax_type) {

			//set custom taxonomy values
			$cpt_label = ( !$cpt_tax_type["label"] ) ? esc_html($cpt_tax_type["name"]) : esc_html($cpt_tax_type["label"]);
			$cpt_singular_label = ( !$cpt_tax_type["singular_label"] ) ? esc_html($cpt_tax_type["name"]) : esc_html($cpt_tax_type["singular_label"]);
			$cpt_rewrite_slug = ( !$cpt_tax_type["rewrite_slug"] ) ? esc_html($cpt_tax_type["name"]) : esc_html($cpt_tax_type["rewrite_slug"]);
			$cpt_post_types = 'books';

			//set custom label values
			$cpt_labels['name'] = $cpt_label;
			$cpt_labels['singular_name'] = $cpt_tax_type["singular_label"];
			$cpt_labels['search_items'] = ( $cpt_tax_type[0]["search_items"] ) ? $cpt_tax_type[0]["search_items"] : 'Search ' .$cpt_label;
			$cpt_labels['popular_items'] = ( $cpt_tax_type[0]["popular_items"] ) ? $cpt_tax_type[0]["popular_items"] : 'Popular ' .$cpt_label;
			$cpt_labels['all_items'] = ( $cpt_tax_type[0]["all_items"] ) ? $cpt_tax_type[0]["all_items"] : 'All ' .$cpt_label;
			$cpt_labels['parent_item'] = ( $cpt_tax_type[0]["parent_item"] ) ? $cpt_tax_type[0]["parent_item"] : 'Parent ' .$cpt_singular_label;
			$cpt_labels['parent_item_colon'] = ( $cpt_tax_type[0]["parent_item_colon"] ) ? $cpt_tax_type[0]["parent_item_colon"] : 'Parent ' .$cpt_singular_label. ':';
			$cpt_labels['edit_item'] = ( $cpt_tax_type[0]["edit_item"] ) ? $cpt_tax_type[0]["edit_item"] : 'Edit ' .$cpt_singular_label;
			$cpt_labels['update_item'] = ( $cpt_tax_type[0]["update_item"] ) ? $cpt_tax_type[0]["update_item"] : 'Update ' .$cpt_singular_label;
			$cpt_labels['add_new_item'] = ( $cpt_tax_type[0]["add_new_item"] ) ? $cpt_tax_type[0]["add_new_item"] : 'Add New ' .$cpt_singular_label;
			$cpt_labels['new_item_name'] = ( $cpt_tax_type[0]["new_item_name"] ) ? $cpt_tax_type[0]["new_item_name"] : 'New ' .$cpt_singular_label. ' Name';
			$cpt_labels['separate_items_with_commas'] = ( $cpt_tax_type[0]["separate_items_with_commas"] ) ? $cpt_tax_type[0]["separate_items_with_commas"] : 'Separate ' .$cpt_label. ' with commas';
			$cpt_labels['add_or_remove_items'] = ( $cpt_tax_type[0]["add_or_remove_items"] ) ? $cpt_tax_type[0]["add_or_remove_items"] : 'Add or remove ' .$cpt_label;
			$cpt_labels['choose_from_most_used'] = ( $cpt_tax_type[0]["choose_from_most_used"] ) ? $cpt_tax_type[0]["choose_from_most_used"] : 'Choose from the most used ' .$cpt_label;

			//register our custom taxonomies
			register_taxonomy( $cpt_tax_type["name"],
				$cpt_post_types,
				array( 'hierarchical' => get_disp_boolean($cpt_tax_type["hierarchical"]),
				'label' => $cpt_label,
				'can_export' => true,
				'show_ui' => get_disp_boolean($cpt_tax_type["show_ui"]),
				'query_var' => get_disp_boolean($cpt_tax_type["query_var"]),
				'rewrite' => array('slug' => $cpt_rewrite_slug),
				'singular_label' => $cpt_singular_label,
				'labels' => $cpt_labels
			) );
			

		}
		}
						$classcat_labels= array(
		'name' => _x( 'Book Class/Category', 'taxonomy general name' ) ,
		'singular_name' =>  _x( 'Book Class/Category', 'taxonomy singular name' ),
		'search_items' => __( 'Search Class/Category' ),
		'popular_items' => __( 'Popular Class/Category' ),
		'all_items' => __( 'All Class/Category' ),
		'parent_item' => null,
		'parent_item_colon' => null,
		'edit_item' => __( 'Edit Class/Category' ),
		'update_item' => ( 'Update Class/Category' ),
		'add_new_item' => __( 'Add New Class/Category') ,
		'new_item_name' => __( 'New Book Class/Category' ),
		'separate_items_with_commas' => __( 'Separate Class/Category with commas' ),
		'add_or_remove_items' => __( 'Add or remove Class/Category' ),
		'choose_from_most_used' => __( 'Choose from the most used Class/Category Name' )
			);
				register_taxonomy( 'classcat',
				'library',
				array( 'hierarchical' => false,
				'label' => __('Editions'),
				'can_export' => true,
				'show_ui' => true,
				'query_var' => true,
				'rewrite' => array('slug' => 'classcat'),
				'singular_label' => 'Edition',
				'labels' =>$classcat_labels )
			);
				$authors_labels= array(
		'name' => _x( 'Book Authors', 'taxonomy general name' ) ,
		'singular_name' =>  _x( 'Book Author', 'taxonomy singular name' ),
		'search_items' => __( 'Search Authors' ),
		'popular_items' => __( 'Popular Authors' ),
		'all_items' => __( 'All Authors' ),
		'parent_item' => null,
		'parent_item_colon' => null,
		'edit_item' => __( 'Edit Author' ),
		'update_item' => ( 'Update Author' ),
		'add_new_item' => __( 'Add New Author') ,
		'new_item_name' => __( 'New Book Author' ),
		'separate_items_with_commas' => __( 'Separate Authors with commas' ),
		'add_or_remove_items' => __( 'Add or remove Authors' ),
		'choose_from_most_used' => __( 'Choose from the most used Authors Name' )
			);
				register_taxonomy( 'authors',
				'library',
				array( 'hierarchical' => false,
				'label' => __('Authors'),
				'can_export' => true,
				'show_ui' => true,
				'query_var' => true,
				'rewrite' => array('slug' => 'authors'),
				'singular_label' => 'Author',
				'labels' =>$authors_labels )
			);

				$publishers_labels= array(
		'name' => _x( 'Book Publishers', 'taxonomy general name' ) ,
		'singular_name' =>  _x( 'Book Publisher', 'taxonomy singular name' ),
		'search_items' => __( 'Search Publishers' ),
		'popular_items' => __( 'Popular Publishers' ),
		'all_items' => __( 'All Publishers' ),
		'parent_item' => null,
		'parent_item_colon' => null,
		'edit_item' => __( 'Edit Publisher' ),
		'update_item' => ( 'Update Publisher' ),
		'add_new_item' => __( 'Add New Publisher') ,
		'new_item_name' => __( 'New Book Publisher' ),
		'separate_items_with_commas' => __( 'Separate Publishers with commas' ),
		'add_or_remove_items' => __( 'Add or remove Publishers' ),
		'choose_from_most_used' => __( 'Choose from the most used Publishers Name' )
			);
				register_taxonomy( 'publishers',
				'library',
				array( 'hierarchical' => false,
				'label' => __('Publishers'),
				'can_export' => true,
				'show_ui' => true,
				'query_var' => true,
				'rewrite' => array('slug' => 'publishers'),
				'singular_label' => 'Publisher',
				'labels' =>$publishers_labels )
			);

				$editions_labels= array(
		'name' => _x( 'Book Editions', 'taxonomy general name' ) ,
		'singular_name' =>  _x( 'Book Edition', 'taxonomy singular name' ),
		'search_items' => __( 'Search Editions' ),
		'popular_items' => __( 'Popular Editions' ),
		'all_items' => __( 'All Editions' ),
		'parent_item' => null,
		'parent_item_colon' => null,
		'edit_item' => __( 'Edit Edition' ),
		'update_item' => ( 'Update Edition' ),
		'add_new_item' => __( 'Add New Edition') ,
		'new_item_name' => __( 'New Book Edition' ),
		'separate_items_with_commas' => __( 'Separate Editions with commas' ),
		'add_or_remove_items' => __( 'Add or remove Editions' ),
		'choose_from_most_used' => __( 'Choose from the most used Editions Name' )
			);
				register_taxonomy( 'editions',
				'library',
				array( 'hierarchical' => false,
				'label' => __('Editions'),
				'can_export' => true,
				'show_ui' => true,
				'query_var' => true,
				'rewrite' => array('slug' => 'editions'),
				'singular_label' => 'Edition',
				'labels' =>$editions_labels )
			);
			

				register_taxonomy( 'dates',
				'library',
				array( 'hierarchical' => false,
				'label' => __('Dates'),
				'can_export' => true,
				'show_ui' => false,
				'query_var' => true,
				'rewrite' => array('slug' => 'dates'),
				'singular_label' => 'Date' )
			);
			 flush_rewrite_rules();
		}
require (WPBL_PLUGIN_PATH.'/includes/add-remove.php');
require (WPBL_PLUGIN_PATH.'/includes/dropdown.php');
require (WPBL_PLUGIN_PATH.'/includes/classcat.php');
require (WPBL_PLUGIN_PATH.'/includes/authors.php');
require (WPBL_PLUGIN_PATH.'/includes/editions.php');
require (WPBL_PLUGIN_PATH.'/includes/publishers.php');
require (WPBL_PLUGIN_PATH.'/includes/sav_tax.php');
		?>